import fly from '../utils/fly.js'
/**
 * 用户注册
 */
export function SendSMSCode(mobile) {
	return fly.request({
		url: '/login/login/smscodeno/'+mobile,
		needToken: false,
		method:'POST'
	})
}
/**
 * 用户登录
 */
export function Login(params) {
	return fly.request({
		url: '/login/loginByWechat',
		needToken: false,
		params:params,
		method:'POST'
	})
}
/**
 * 微信自动登录
 */
export function AutoLogin(params) {
	return  fly.request({
		url: '/passport/mini-program/auto-login',
		needToken: false,
		params:params,
		method:'GET'
	})
}
/**
 * 微信自动登录
 */
export function PhoneLogin(params) {
	return  fly.request({
		url: '/login/loginOrRegist',
		needToken: false,
		params:params,
		method:'POST'
	})
}

/**
 * 查询用户自己的角色
 */
export function checkRole(params) {
	return  fly.request({
		url: '/applet/user/findToRole',
		needToken: true,
		params:params,
		method:'POST'
	})
}
/**
 * 查询会员商品收藏列表
 */
export function getCollectionList(params) {
	return fly.get({
		url: `/members/collection/goods`,
		needToken: true,
		loading:false,
		params
	})
}
/**
 * 向购物车中添加一个产品
 */
export function addGoodCollection(params) {
	return fly.request({
		url: `/members/collection/goods`,
		needToken: true,
		params:params,
		method:"POST"
	})
}
/**
 * 清空购物车
 */
export function delCollectionGood(goods_id) {
	return fly.request({
		url: `/members/collection/goods/`+goods_id,
		needToken: true,
		method:'DELETE'
	})
}
/**
 * 查询会员是否收藏商品
 */
export function checkCollection(id) {
	return fly.get({
		url: `/members/collection/goods/`+id,
		needToken: true
	})
}